From 956eabb460f52d24bd983731cdef07a3cf0bdc82 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 22 Jan 2008 11:18:10 +0000 Subject: [PATCH] hvmloader: Expand iomem allocation pool to 0xf0000000-0xfc000000. Check for exhaustion of allocation pool, warn user, and fail to initialise the relevant PCI BAR. Signed-off-by: Keir Fraser --- tools/firmware/hvmloader/acpi/build.c | 2 +- tools/firmware/hvmloader/hvmloader.c | 33 +++++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c index 1323b17065..247c3b5928 100644 --- a/tools/firmware/hvmloader/acpi/build.c +++ b/tools/firmware/hvmloader/acpi/build.c @@ -76,7 +76,7 @@ static int construct_bios_info_table(uint8_t *buf) bios_info->com2_present = uart_exists(0x2f8); bios_info->pci_min = 0xf0000000; - bios_info->pci_len = 0x05000000; + bios_info->pci_len = 0x0c000000; return align16(sizeof(*bios_info)); } diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 59c6e74512..ce6f8a063c 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -183,11 +183,17 @@ static void apic_setup(void) static void pci_setup(void) { - uint32_t devfn, bar_reg, bar_data, bar_sz, cmd; - uint32_t *base, io_base = 0xc000, mem_base = HVM_BELOW_4G_MMIO_START; + uint32_t base, devfn, bar_reg, bar_data, bar_sz, cmd; uint16_t class, vendor_id, device_id; unsigned int bar, pin, link, isa_irq; + /* Resources assignable to PCI devices via BARs. */ + struct resource { + uint32_t base, max; + } *resource; + struct resource mem_resource = { 0xf0000000, 0xfc000000 }; + struct resource io_resource = { 0xc000, 0x10000 }; + /* Create a list of device BARs in descending order of size. */ struct bars { uint32_t devfn, bar_reg, bar_sz; @@ -301,22 +307,31 @@ static void pci_setup(void) if ( (bar_data & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY ) { - base = &mem_base; + resource = &mem_resource; bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK; } else { - base = &io_base; + resource = &io_resource; bar_data &= ~PCI_BASE_ADDRESS_IO_MASK; } - *base = (*base + bar_sz - 1) & ~(bar_sz - 1); - bar_data |= *base; - *base += bar_sz; + base = (resource->base + bar_sz - 1) & ~(bar_sz - 1); + bar_data |= base; + base += bar_sz; + + if ( (base < resource->base) || (base > resource->max) ) + { + printf("pci dev %02x:%x bar %02x size %08x: no space for " + "resource!\n", devfn>>3, devfn&7, bar_reg, bar_sz); + continue; + } + + resource->base = base; pci_writel(devfn, bar_reg, bar_data); - printf("pci dev %02x:%x bar %02x size %08x: %08x %08x/%08x\n", - devfn>>3, devfn&7, bar_reg, bar_sz, bar_data, i, nr_bars); + printf("pci dev %02x:%x bar %02x size %08x: %08x\n", + devfn>>3, devfn&7, bar_reg, bar_sz, bar_data); /* Now enable the memory or I/O mapping. */ cmd = pci_readw(devfn, PCI_COMMAND); -- 2.30.2